<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
    <link rel="stylesheet" href="../css/paixu.css">
    <link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css">
</head>
<body>
<div style="float: left;margin-left: 32%;" >
    <p>输入内容请用空格隔开</p>
    <textarea id="dd" cols="30" rows="10"></textarea>
    <div>
        <button class="btn"  onclick="fun()" ><b>一键排序</b></button>
    </div>
</div>
<div class="aa">
    <p>排序结果：</p>
    <textarea class="pp" cols="30" rows="10"></textarea>
</div>
</body>
<script>
    function fun() {
        var string = document.getElementById("dd").value;//原始数据
        var array = string.split(" "); //转化为数组
        $(".pp").empty();
        var l=array.length;
        for(i=0;i<l;i++){
            n=Math.floor(Math.random()*(array.length));
            $(".pp").append(array[n]+' '); //随机选取
            array.splice(n,1)
        }
    }
</script>
</html>